package com.zrwl.poscloud.core.restapi.admin.baseInfo;

import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.core.annotion.OperationLogger.OperationLogger;
import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.Delete;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.commons.validator.group.Insert;
import com.zrwl.poscloud.commons.validator.group.Update;
import com.zrwl.poscloud.xo.service.ServerSyncEmployeeInfoService;
import com.zrwl.poscloud.xo.vo.ServerSyncEmployeeInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户关注持卡人云端数据 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2022-03-30
 */
@RestController
@Api(value = "用户关注持卡人云端数据相关接口", tags = {"用户关注持卡人云端数据相关接口"})
@RequestMapping("/serverSyncEmployeeInfo")
@Slf4j
public class ServerSyncEmployeeInfoRestApi {
    @Autowired
    private ServerSyncEmployeeInfoService serverSyncEmployeeInfoService;
    @AuthorityVerify
    @ApiOperation(value = "获取用户关注持卡人云端数据列表", notes = "获取用户关注持卡人云端数据列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody ServerSyncEmployeeInfoVO serverSyncEmployeeInfoVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取用户关注持卡人云端数据列表: {}", serverSyncEmployeeInfoVO);
        return ResultUtil.successWithData(serverSyncEmployeeInfoService.getPageList(serverSyncEmployeeInfoVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取用户关注持卡人云端数据列表", notes = "获取用户关注持卡人云端数据列表", response = String.class)
    @PostMapping("/getAllList")
    public String getAllList(@Validated({GetList.class}) @RequestBody ServerSyncEmployeeInfoVO serverSyncEmployeeInfoVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取用户关注持卡人云端数据列表: {}", serverSyncEmployeeInfoVO);
        return ResultUtil.successWithData(serverSyncEmployeeInfoService.getAllList(serverSyncEmployeeInfoVO));
    }

    @AuthorityVerify
    @OperationLogger(value = "新增用户关注持卡人云端数据")    @ApiOperation(value = "新增用户关注持卡人云端数据", notes = "新增用户关注持卡人云端数据", response = String.class)
    @PostMapping("/add")
    public String add(@Validated({Insert.class}) @RequestBody ServerSyncEmployeeInfoVO serverSyncEmployeeInfoVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("新增用户关注持卡人云端数据: {}", serverSyncEmployeeInfoVO);
        return serverSyncEmployeeInfoService.add(serverSyncEmployeeInfoVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "修改用户关注持卡人云端数据")    @ApiOperation(value = "修改用户关注持卡人云端数据", notes = "修改用户关注持卡人云端数据", response = String.class)
    @PostMapping("/edit")
    public String edit(@Validated({Update.class}) @RequestBody ServerSyncEmployeeInfoVO serverSyncEmployeeInfoVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("修改用户关注持卡人云端数据: {}", serverSyncEmployeeInfoVO);
        return serverSyncEmployeeInfoService.edit(serverSyncEmployeeInfoVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "删除用户关注持卡人云端数据")    @ApiOperation(value = "删除用户关注持卡人云端数据", notes = "删除用户关注持卡人云端数据", response = String.class)
    @PostMapping("/delete")
    public String delete(@Validated({Delete.class}) @RequestBody ServerSyncEmployeeInfoVO serverSyncEmployeeInfoVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("删除用户关注持卡人云端数据: {}", serverSyncEmployeeInfoVO);
        return serverSyncEmployeeInfoService.delete(serverSyncEmployeeInfoVO);
    }

}
